#include "ui_BearPi.h"
#include "ui_BearPiLogic.h"
#include "LL_General.h"
#include "LL_Handler.h"
#include "LL_Linked_List.h"
#include "LL_Timer.h"
#include "LL_ButtonEx.h"

static uint32_t Timer_0=0;

void ui_BearPiInit(void)
{
    //背景
    llBackgroundQuickCreate(ID_BACKGROUND,240,240,true,RGB888(0xf1f1f1),0);

    //按键
    llButtonQuickCreate(ID_BUTTON_0,ID_BACKGROUND,30,30,80,30,(uint8_t *)"BearPi",FONT_LIB_C_SIMSUN_9,RGB888(0x000000),RGB888(0x55aaff),RGB888(0x55aaff),0xFFFFFFFF,0xFFFFFFFF,BUTTON_DIS_TYPE_COLOR,false);
    nButtonSetEnabled(ID_BUTTON_0,true);
    nButtonSetCheckable(ID_BUTTON_0,false);
    nButtonSetKeyValue(ID_BUTTON_0,0);

    //按键
    llButtonQuickCreate(ID_BUTTON_1,ID_BACKGROUND,30,80,80,30,(uint8_t *)"Button",FONT_LIB_C_SIMSUN_9,RGB888(0x000000),RGB888(0x55aaff),RGB888(0x55aaff),0xFFFFFFFF,0xFFFFFFFF,BUTTON_DIS_TYPE_COLOR,false);
    nButtonSetEnabled(ID_BUTTON_1,true);
    nButtonSetCheckable(ID_BUTTON_1,false);
    nButtonSetKeyValue(ID_BUTTON_1,0);

    //按键
    llButtonQuickCreate(ID_BUTTON_2,ID_BACKGROUND,130,30,80,30,(uint8_t *)"IOT",FONT_LIB_C_SIMSUN_9,RGB888(0x000000),RGB888(0x55aaff),RGB888(0x55aaff),0xFFFFFFFF,0xFFFFFFFF,BUTTON_DIS_TYPE_COLOR,false);
    nButtonSetEnabled(ID_BUTTON_2,true);
    nButtonSetCheckable(ID_BUTTON_2,false);
    nButtonSetKeyValue(ID_BUTTON_2,0);

    //文本
    llTextQuickCreate(ID_TEXT_0,ID_BACKGROUND,130,80,80,30,(uint8_t *)"text",FONT_LIB_C_SIMSUN_9,RGB888(0x000000),RGB888(0xffffff),llAlignHLeft,llAlignVTop,0,0,false,false,false);
    nTextSetEnabled(ID_TEXT_0,true);

    llLineEditQuickCreate(ID_LINEEDIT_0,ID_BACKGROUND,30,130,120,20,(uint8_t *)"",FONT_LIB_C_SIMSUN_9,RGB888(0x000000),FONT_LIB_C_SIMSUN_9,false);
    nLineEditSetKeyboard(ID_LINEEDIT_0,0);
    nLineEditSetEnabled(ID_LINEEDIT_0,true);

    llCheckBoxQuickCreate(ID_CHECKBOX_0,ID_BACKGROUND,30,170,120,20,(uint8_t *)"Check Box",FONT_LIB_C_SIMSUN_9,RGB888(0x000000),false,false);
    nCheckBoxSetEnabled(ID_CHECKBOX_0,true);

    llProgressBarQuickCreate(ID_PROGRESSBAR_0,ID_BACKGROUND,30,210,190,20,FONT_LIB_C_SIMSUN_9,0, RGB_CONVERT(230,230,230), RGB_CONVERT(6,176,37),24,false);
    nProgressBarSetEnabled(ID_PROGRESSBAR_0,true);


    llTimer_start(&Timer_0);
    ui_BearPiLogicInit();
}

void ui_BearPiLoop(void)
{
    if(llTimer_timeOut(&Timer_0,1000,true))
    {
        ui_BearPiTimer_Timer_0();
    }

    ui_BearPiLogicLoop();
}

void ui_BearPiQuit(void)
{
    ui_BearPiLogicQuit();
}

